from django.db import models

# Create your models here.
from django.db import models


class User(models.Model):
    id = models.IntegerField(db_column="id", primary_key=True, null=False)  # 学号，不允许为空，主键
    username = models.CharField(db_column="username", max_length=100, null=False)  # 姓名，最长100个字符，不允许为空
    password = models.CharField(db_column="password",max_length=100,null=False)
    # 在默认情况下，生成的表名：App_class, 如果要自定义 ，需要使用Class Meta来自定义
    class Meta:
        managed = True
        db_table = "user" #指定真实表名
    # __str__方法
    def __str__(self):
        return "id:%s\t用户名:%s\t密码:%s\t" %(self.id,self.username,self.password)
class Rights(models.Model):
    id = models.IntegerField(db_column="id", primary_key=True, null=False)  # 学号，不允许为空，主键
    name = models.CharField(db_column="name", max_length=100, null=False)  # 姓名，最长100个字符，不允许为空
    parent_id = models.IntegerField(db_column="parent_id", null=False)
    path = models.CharField(db_column="path", max_length=100, null=True)
    level =models.IntegerField(db_column="level",null=False)
    class Meta:
        managed = True
        db_table = "rights"  # 指定真实表名

class Ecm(models.Model):
    id = models.IntegerField(db_column="id",primary_key=True,null=False)#每一配电柜类型序号,主键
    name = models.CharField(db_column="name",max_length=100,null=False)#配电柜型号名称,不允许为空
    size = models.CharField(db_column="size", max_length=100, null=False)  # 配电柜型号尺寸,不允许为空
    width= models.CharField(db_column="width", max_length=100, null=False)  # 配电柜型号宽度,不允许为空
    height = models.CharField(db_column="height", max_length=100, null=False)  # 配电柜型号高度,不允许为空
    depth = models.CharField(db_column="depth", max_length=100, null=False)  # 配电柜型号深度,不允许为空
    k = models.CharField(db_column="k", max_length=100, null=False)  # 配电柜型号换热系数,不允许为空python manage.py makemigrations

    class Meta:
        managed=True
        db_table="ecm"

#当前项目选择的配电柜数据
class Projectec(models.Model):
    id = models.IntegerField(db_column="id",primary_key=True,null=False)# 当前项目的配电柜数据序号,主键
    ecm = models.CharField(db_column="ecm", max_length=100, null=False)  # 选择的配电柜型号名称,不允许为空
    ecz = models.CharField(db_column="ecz", max_length=100, null=False)  # 选择的配电柜型号尺寸,不允许为空
    ecp = models.CharField(db_column="ecp",max_length=100,null=False)# 选择的配电柜的摆放位置,不允许为空
    heatloss = models.CharField(db_column=" heatloss",max_length=100)# 选择的配电柜的热损耗数据
    ecw = models.CharField(db_column="ecw", max_length=100, null=False)  # 选择的配电柜型号宽度,不允许为空
    ech = models.CharField(db_column="ech", max_length=100, null=False)  # 选择的配电柜型号高度,不允许为空
    ecd = models.CharField(db_column="ecd", max_length=100, null=False)  # 选择的配电柜型号宽度,不允许为空
    eck = models.CharField(db_column="eck", max_length=100, null=False)  # 选择的配电柜型号换热系数,不允许为空
    class Meta:
        managed=True
        db_table="projectec"
class HeatDevice(models.Model):
    id = models.IntegerField(db_column="id", primary_key=True, null=False)  # 当前项目的配电柜数据序号,主键
    group=models.CharField(db_column="group", max_length=100, null=False)  #组件群
    device = models.CharField(db_column="device", max_length=100, null=False)  #装置名
    num = models.IntegerField(db_column="num", null=False)  #器件数量
    heat_before = models.CharField(db_column="heat_before", max_length=100, null=False)  #原热损耗
    factor = models.CharField(db_column="factor", max_length=100, null=False)  #因素
    heat_after = models.CharField(db_column="heat_after", max_length=100, null=False)  #后 热损耗
    class Meta:
        managed=True
        db_table="heat_device"
class HeatLoss(models.Model):
    id = models.IntegerField(db_column="id", primary_key=True, null=False)  # 当前项目热损耗器件 序号
    manu = models.CharField(db_column="manu", max_length=100, null=False)  #  制造商
    group = models.CharField(db_column="group", max_length=100,null=False)  # 组件群
    dloss = models.CharField(db_column="dloss", max_length=100, null=False)  # 装置库
    name = models.CharField(db_column="name", max_length=100, null=False)  # 元器件信息
    capacity = models.CharField(db_column="capacity", max_length=100, null=False)  # 容量
    value = models.CharField(db_column="value", max_length=100, null=False)  #
    class Meta:
        managed=True
        db_table="heat_loss"